package com.passionfruit.common.utils;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by weirdor on 2017/10/27.
 */
public class PropertiesUtil {
    /**

     * 创建对象

     */
    private Properties props=null;

    public PropertiesUtil() throws IOException {
        InputStream in = PropertiesUtil.class.getClassLoader().getResourceAsStream("mongo.properties");
        props = new Properties();
        if(in == null){
            System.out.println("文件为空");
        }else{
            props.load(in);
        }
        //关闭资源
        in.close();
    }
    public String readProperties(String name) throws FileNotFoundException,IOException  {
        //保存所有的键值

        String Property = "";
        if(name !=null){
            Property = props.getProperty(name);
        }
        return Property;
    }
}